package com.fuda.trade
import com.fuda.trade.model.Heartbeat
import org.junit.jupiter.api.Test

import org.junit.jupiter.api.Assertions

class HeartbeatUnitTest {
    @Test
    fun serialize_isCorrect() {
        val server = Heartbeat.Server(id = "1", timestampMs = System.currentTimeMillis(), desc = "heartbeat@HeartbeatUnitTest.kt" )
        val payload = Heartbeat.serialize(server  )

        val heartbeat = Heartbeat.deserialize(payload)

        when (heartbeat){
            is Heartbeat.Server -> {
                Assertions.assertEquals(heartbeat.id, "1")
            }

            is Heartbeat.AccessibilityService -> {
                Assertions.assertEquals(heartbeat.id, "1")
            }
        }

        println("\n\nserialized heartbeat= $payload\n")

        Assertions.assertEquals(server, heartbeat)
    }
}